package com.thirdgroup.service.impl;

import com.thirdgroup.dao.BillingDao;
import com.thirdgroup.dao.BillingOrderDao;
import com.thirdgroup.dao.CompanyInfoDao;
import com.thirdgroup.dao.impl.BillingDaoImpl;
import com.thirdgroup.dao.impl.BillingOrderDaoImpl;
import com.thirdgroup.dao.impl.CompanyInfoDaoImpl;
import com.thirdgroup.pojo.entity.CompanyInfo;
import com.thirdgroup.service.CompanyService;
import com.thirdgroup.utils.respond.R;

public class CompanyServiceImpl implements CompanyService {
    private CompanyInfoDao companyInfoDao=new CompanyInfoDaoImpl();
    private BillingOrderDao billingOrderDao=new BillingOrderDaoImpl();
    private BillingDao billingDao=new BillingDaoImpl();
    @Override
    public R select() {
        double sum = billingDao.Sum() + billingOrderDao.Sum();
        Integer integer = companyInfoDao.updateAsset(sum);
        CompanyInfo select = companyInfoDao.select();
        if (select!=null&&!"".equals(select)){
            return R.ok(select,"总资产更新成功");
        }
        System.out.println("系统繁忙，请稍后再试~");
        return R.error(500,"系统繁忙，请稍后再试~");
    }
}
